package cn.tedu.charging.common.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")//表示在后端允许匹配客户端发过来的任意请求
                .allowedHeaders("*").//请求带任意头都可以
                allowedMethods("*").//任意请求方式都可以
                allowedOriginPatterns("*")//
                .allowCredentials(true).maxAge(3600);
    }
}
